package com.cqut.forum.util;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

/**
 * 单独处理ajax向客户端异步发送数据
 * @author yangxun
 */
public abstract class ResponsePrintWriter {
	public static void printWriterString(HttpServletResponse response,String result){
		response.setContentType("text/javascript;charset=UTF-8");
		response.setHeader("Cache-Control","no-store, max-age=0, no-cache, must-revalidate");     
		response.addHeader("Cache-Control", "post-check=0, pre-check=0"); 
		response.setHeader("Pragma", "no-cache");
		PrintWriter out = null;
		try {
			out = response.getWriter();
			out.write(result);
			out.flush();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
